Computer systems output data to a variety of output devices, such as, printers, plotters, and video displays. Each device typically has a manufacturer defined device-specific protocol for communicating with the device. A computer system, under the control of an operating system, uses the protocol to communicate with a device. Thus, an operating system must know the protocol for each device to which it communicates. It would be impractical for an operating system developer to provide an interface to every available output device. Moreover, it would be impracticable to provide an interface to output devices that have not yet been developed. To overcome these difficulties, operating systems interface with devices indirectly through device drivers. The operating system developer defines the functionality of the operating system/device driver interface. Each manufacturer of a device then provides a device driver, which implements the operating system/device driver interface that is consistent with the device protocol. The operating system loads the device driver and invokes its functions to communicate with the device.
A primary goal of operating systems is to provide an application program environment which is output device independent. This independence means that an application program can output its data to various types of devices without modification of the program. For example, an operating system can redirect output of application program data to a display, printer, or file without the application program being aware of the redirection.
FIG. 1 is a block diagram illustrating a prior device driver configuration. Computer system 100 comprises application program 101, graphics device interface 102, and device drivers 103. Each device driver interfaces with a device 105 that is attached to computer system 100. Application program 101 outputs data using functions provided by the graphics device interface (GDI) 102, which is typically part of an operating system. The GDI effects the output of data by invoking functions implemented by the device drivers 103 in accordance with the operating system/device driver interface. The graphics device interface and device drivers insulate the application program from the different characteristics of the devices. The GDI provides a variety of functions for accessing the devices in a device-independent manner.
The developer of a graphics device interface provides a definition of its functionality to the developers of application programs. An example of such a graphics device interface is described in Programming Windows 3.1 by Charles Petzold, published by Microsoft Press. The developer of the graphics device interface also specifies the behavior of each function that a device driver (the operating system/device driver interface) must implement. For example, one graphics device interface specifies six categories of functions that must be implemented by a device driver: (1) initialization, (2) information, (3) output, (4) attribute, (5) mode, and (6) escape. In the following, reference is specifically made to outputting data to a printer. One skilled in the art would appreciate that such references also apply to other output devices. Each of the functions that must be implemented by a device driver is described.
______________________________________ Function Description ______________________________________ (1) Initialization Control performs device-dependent operations such as starting an output job, aborting an output job, and processing a new band of bitmap data. Disable deallocates memory used by the device drivers data structures and unloads the device driver from memory. Enable allocates and initializes memory for a data structure containing device dependent and device state information. WEP signals the device driver that the operating system is shutting down. (2) Information ColorInfo translates physical colors to logical colors and vice versa. EnumDFonts enumerates the fonts available on the device. EnumObj enumerates the pens and brushes that are available on the device. DevGetCharWidth returns width values for characters in a specified printer font. (3) Output DevBitBlt sets pels on the output device. DevExtTextOut renders text on the output device. Output renders a shape on the output device. Pixel sets a single pel on the output device. ScanLR sets pels in a single row of the output device. StretchBlt renders scaled bitmaps on the output device. (4) Attributes RealizeObject converts a logical pen, brush, font, etc. data structure to a physical pen, brush, font, etc. data structure. (5) Modes DeviceMode displays a dialog box that allows a user to select device options such as paper size, paper orientation, and output quality. (6) Escape QueryEscSupport specifies whether the output device supports a specified escape sequence. SetAbortDoc invokes the abort procedure of an application program. StartDoc signals the beginning of an output job. NextBand outputs a band of bitmap data. EndDoc signals the end of an output job. AbortDoc signals the abnormal termination of an output job. ______________________________________
An application program outputs data to a particular device by first requesting the graphics device interface to create a device context. The device context identifies the particular device and contains the current state of the device. For example, the device context may contain the current font and paintbrush information. The graphics device interface provides the application program with a handle to a created device context. Whenever the application program outputs data to the particular device, the application program passes the handle to the device context. The graphics device interface functions use the passed handle to access the device context.
When developing a device driver, the developer codes, tests, and debugs each device driver function. This process requires a thorough understanding to the windowing environment, the graphics device interface, the device hardware, and the device communications protocol. This development process is complex, time consuming, and costly.